<?php
declare(strict_types=1);

namespace Dreamcat\ApiDoc\Error;

use JetBrains\PhpStorm\ExpectedValues;
use JetBrains\PhpStorm\Pure;
use RuntimeException;
use Throwable;

/**
 * 文档生成器异常
 * @author vijay
 */
class GeneratorError extends RuntimeException
{
    /** @var int 变量路径不支持多级变量 */
    public const VAR_PATH_CANT_MUL = 1001001;
    /** @var int 变量必须是标量 */
    public const VAR_MUST_SCALA = 1001002;
    /** @var int 路径变量没定义 */
    public const PATH_VAR_UNDEFINED = 1001003;

    /**
     * @param string $message 异常信息
     * @param int $code 异常码
     * @param ?Throwable $previous 异常链的前一异常
     */
    #[Pure]
    public function __construct(
        string $message,
        #[ExpectedValues(valuesFromClass: GeneratorError::class)]
        int $code,
        Throwable $previous = null
    ) {
        parent::__construct($message, $code, $previous);
    }
}

# end of file
